import { getCalendar, formDate } from './calendar';
import { getWeather } from './weather';
import { getQRCode } from './qrcode';
import axios from 'axios';

axios.interceptors.response.use(
  response => {
    // console.log(response);
    // return response.data;
    if (!response.data.result) {
      const reason = response.data.reason;
      alert(reason);
      return Promise.reject(reason);
    }
    // 聚合的数据 有的直接在 result 里， 有的又包了一层data
    return response.data.result?.data
      ? response.data.result.data
      : response.data.result;
  },
  err => Promise.reject(err)
);

export { getCalendar, formDate, getWeather, getQRCode };
